<?php

/**
 * Radcodes - SocialEngine Module
 *
 * @category   Application_Extensions
 * @package    Story
 * @copyright  Copyright (c) 2009-2010 Radcodes LLC (http://www.radcodes.com)
 * @license    http://www.radcodes.com/license/
 * @version    $Id$
 * @author     Vincent Van <vincent@radcodes.com>
 */


class Story_Form_Create_Privacy extends Engine_Form
{


    public function init()
    {
        $user = Engine_Api::_()->user()->getViewer();
        $user_level = Engine_Api::_()->user()->getViewer()->level_id;

        // View
        $availableLabels = array(
            'everyone' => 'Everyone',
            'registered' => 'Registered Members',
            'owner_network' => 'Friends and Networks',
            'owner_member_member' => 'Friends of Friends',
            'owner_member' => 'Friends Only',
            'owner' => 'Just Me');


        $options = (array )Engine_Api::_()->authorization()->getAdapter('levels')->
            getAllowed('story', $user, 'auth_view');
        $options = array_intersect_key($availableLabels, array_flip($options));

        $this->addElement('Select', 'extend_auth_view', array(
            //'label' => 'Privacy',
            'description' => 'Who may see this story?',
            'multiOptions' => $options,
            'value' => 'everyone',
            ));
        $this->extend_auth_view->getDecorator('Description')->setOption('placement', 'prepend');
        $this->extend_auth_view->removeDecorator('Label');

        $options = (array )Engine_Api::_()->authorization()->getAdapter('levels')->
            getAllowed('story', $user, 'auth_comment');
        $options = array_intersect_key($availableLabels, array_flip($options));

        //Comment
        $this->addElement('Select', 'extend_auth_comment', array(
            //'label' => 'Comment Privacy',
            'description' => 'Who may post comments on this story?',
            'multiOptions' => $options,
            'value' => 'registered',
            ));
        $this->extend_auth_comment->getDecorator('Description')->setOption('placement',
            'prepend');

        $this->extend_auth_comment->removeDecorator('Label');

    }

}
